﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using EC18_ESHOP.Models;

namespace EC18_ESHOP.Controllers
{
    public class CheckoutController : Controller
    {
        //
        // GET: /Checkout/
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Index(string[] product, string[] finalprice, string[] quantity)
        {
            bool useSandbox = Convert.ToBoolean(ConfigurationManager.AppSettings["IsSandbox"]);
            var paypal = new PayPalModel(useSandbox);
            //paypal.item_name = product;
            //paypal.amount = totalPrice;
            //var item = new Item() { item_name = product, amount = price, quantity = 1 };
            //paypal.ListItem.Add(item);
            //item = new Item() { item_name = product, amount = price, quantity = 2 };
            //paypal.ListItem.Add(item);
            //paypal.item_name_1 = product;
            //paypal.amount_1 = totalPrice;
            //paypal.item_name_2 = product;
            //paypal.amount_2 = totalPrice;
            for (int i = 0; i < product.Length; i++)
            {
                var item = new Item() { item_name = product[i], amount = finalprice[i], quantity = int.Parse(quantity[i]) };
                paypal.ListItem.Add(item);
            }
            return View(paypal);
        }

        
    }
}
